from django.db import models
from apps.common.base.models import BaseModel

from apps.merchant.item.models import Item
from apps.interface.client.models import Client

class Advert(BaseModel):

    status = (
        ("initial", "草稿"),
        ("checking", "审核中"),
        ("publish", "已投放"),
    )
    clientname = models.ForeignKey(Client, related_name='advert_client', to_field='clientname', verbose_name='客户端', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)

    item = models.ForeignKey(Item, related_name='advert_item', verbose_name='商品', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    types=models.CharField("类型", max_length=200, blank=True, default='')
    title=models.CharField("标题", max_length=200, blank=True, default='')
    content=models.CharField("内容", max_length=200, blank=True, default='')
    link=models.CharField("跳转地址", max_length=200, blank=True, default='')
    coverUrl = models.CharField("封面", max_length=200, blank=True, default='')
    iconUrl = models.CharField("图标", max_length=200, blank=True, default='')
    status = models.CharField("名称", max_length=200, choices=status, blank=True, default='publish')
    query = models.CharField("参数", max_length=10000, blank=True, null=True, default='')
    
    isShow=models.BooleanField("是否显示", blank=True, default=True)
    # 图标样式
    isShowForIcon=models.BooleanField("是否显示图标", blank=True, default=True)
    nameForIcon=models.CharField("图标名称", max_length=200, blank=True, default='')
    colorForIcon=models.CharField("图标颜色", max_length=200, blank=True, default='#333333')
    sizeForIcon=models.CharField("图标大小", max_length=200, blank=True, default='30')
    widthForIcon=models.CharField("icon宽", max_length=200, blank=True, default='100')
    heightForIcon=models.CharField("icon高", max_length=200, blank=True, default='100')
    borderRadiusForIcon=models.CharField("图标圆角", max_length=200, blank=True, default='0')

    # 标题样式
    isShowForTitle=models.BooleanField("是否显示标题", blank=True, default=True)
    colorForTitle=models.CharField("title颜色", max_length=200, blank=True, default='#333333')
    fontsizeForTitle=models.CharField("title字体大小", max_length=200, blank=True, default='30')
    lineHeightForTitle=models.CharField("title行高", max_length=200, blank=True, default='')
    fontweightForTitle=models.CharField("title字体粗细", max_length=200, blank=True, default='')

    # 内容样式
    isShowForContent=models.BooleanField("是否显示标题", blank=True, default=True)
    colorForContent=models.CharField("content颜色", max_length=200, blank=True, default='#333333')
    fontsizeForContent=models.CharField("content字体大小", max_length=200, blank=True, default='30')
    lineHeightForContent=models.CharField("content行高", max_length=200, blank=True, default='')
    fontweightForContent=models.CharField("content字体粗细", max_length=200, blank=True, default='')

    class Meta:
        verbose_name = 'Advert'
        verbose_name_plural = verbose_name